package otherTabs;

import java.awt.Color;
import java.awt.GridLayout;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import javax.swing.JPanel;
import javax.swing.JTextField;

@SuppressWarnings("serial")
public class UpdateLog extends JPanel
{
	private int lineCounter = 1;
	
	public UpdateLog()
	{
		setLayout(new GridLayout(21, 2));
		setBackground(Color.BLACK);
		for(int i = 0; i < 42; i++)
		{
			try{
				add(new JTextField(getFile("update.upd")));
			} catch (NumberFormatException e){
				e.printStackTrace();
			} catch (IOException e){
				e.printStackTrace();
			}
			lineCounter++;
		}
	}
	public String getFile(String filename) throws NumberFormatException,  IOException
	{
		filename = "DataDO/" + filename;
		BufferedReader file = new BufferedReader(new FileReader(filename));
		while(true)
		{
			String line = file.readLine();
			if(line == null) break;
			if(line.startsWith("" + lineCounter))
			{
				return line.substring(3);
			}
		}
		return null;
	}
}
